package com.xingkeduo.business.operation.service;

import com.xingkeduo.dao.database.DatabaseAccessObject;
import com.xingkeduo.pojo.query.HairstyleTagsQuery;
import com.xingkeduo.pojo.table.HairstyleTagsTable;
import com.xingkeduo.util.pojo.domain.Page;
import com.xingkeduo.util.tool.CommonUtil;
import com.xingkeduo.util.tool.IdentityUtil;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 文件概述
 *
 * @author chenxiangda <chenxiangda@xingkeduo.com>
 * @version id:v0.1 ${date}${time}
 * @package BeautyOS
 * @copyright Copyright (c) XKD 2019
 */
@Component
public class HairstyleTagsService {
    private static final String NAMESPACE = HairstyleTagsTable.class.getSimpleName();

    @Resource(name = "mysqlOperationDao")
    private DatabaseAccessObject<HairstyleTagsTable, HairstyleTagsQuery> dao;

    //查询一条
    public HairstyleTagsTable selectById(long id) throws Throwable {
        HairstyleTagsTable hairstyleTagsTable = dao.select(NAMESPACE, id);
        if (!CommonUtil.isEmpty(hairstyleTagsTable))
            return hairstyleTagsTable;
        return null;
    }

    //查询一条
    public HairstyleTagsTable selectByCode(long code) throws Throwable {
        HairstyleTagsTable hairstyleTagsTable = dao.select(NAMESPACE, code);
        if (!CommonUtil.isEmpty(hairstyleTagsTable))
            return hairstyleTagsTable;
        return null;
    }

    //查询多条
    public List<HairstyleTagsTable> selectHairstyleTagss(HairstyleTagsQuery hairstyleTagsQuery) throws Throwable {
        List<HairstyleTagsTable> hairstyleTagsTableList = dao.select(NAMESPACE, hairstyleTagsQuery);
        if (!CommonUtil.isEmpty(hairstyleTagsTableList))
            return hairstyleTagsTableList;
        return null;
    }

    //分页查询
    public Page<HairstyleTagsTable> selectPageLists(HairstyleTagsQuery hairstyleTagsQuery, Integer pageNo, Integer pageSize) throws Throwable {
        Page<HairstyleTagsTable> hairstyleTagsTablePage = dao.pageSelect(NAMESPACE,hairstyleTagsQuery,pageNo,pageSize);
        return hairstyleTagsTablePage;
    }

    //插入
    public int insert(HairstyleTagsTable hairstyleTagsTable) throws Throwable {
        Long code = IdentityUtil.nextId(IdentityUtil.Worker.DEFAULT);
        hairstyleTagsTable.setCode(code);
        return dao.insert(NAMESPACE, hairstyleTagsTable);
    }

    //更新
    public int update(HairstyleTagsTable hairstyleTagsTable) throws Throwable {
        return dao.update(NAMESPACE, hairstyleTagsTable);
    }
    //删除
    public int delete(HairstyleTagsTable hairstyleTagsTable) throws Throwable {
        return dao.update(NAMESPACE, hairstyleTagsTable);
    }

    //批量
    public int updateRows(HairstyleTagsTable hairstyleTagsTable,HairstyleTagsQuery hairstyleTagsQuery) throws Throwable {
        return dao.update(NAMESPACE,hairstyleTagsTable,hairstyleTagsQuery);
    }





}
